home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / dbf_tc.zip / DBF.H < prev    next >
Text File  |  1987-06-18  |  3KB  |  80 lines

  1. /* 
  2. **        file:        dbf.h
  3. **        purpose:    header file defining structures and error codes for dbase access
  4. **                    routines.
  5. **        notes:    this file must be included in any programs which use the dbase
  6. **                    access routines included in dbf.lib.  do not use -a option with
  7. **                    this header file.
  8. **        author:    Mark Sadler
  9. **        revised:    6/18/87
  10. */ 
  11.  
  12. #define        DB2FILE            2
  13. #define        DB3FILE            3
  14. #define        DB3WITHMEMO        0x83
  15. #define        FIELD_REC_LEN    32        /*    length of field description record */
  16. #define        HEADER_PROLOG    32        /*    length of header without field desc and terminator */
  17. #define        MAX_HEADER        4129    /*    maximum length of dBase III header    */
  18. #define        MAX_RECORD        4000    /*    dBase III record limit */
  19. #define        MAX_FIELDS        128    /*    dBase III field limit */
  20. #define        MAX_MEMO_BYTES    512    /*    dBase III memo field record size */
  21.  
  22. #define         MAXPATH            80
  23. /* error codes */
  24. #define        OUT_OF_MEM        8        /*    insufficient memory error */
  25. #define        NO_FILE            2        /*    file not found error */
  26. #define        BAD_FORMAT        11        /*    file not dBASE III file */
  27. #define        RECNO_TOO_BIG    105    /*    requested record too big */
  28.  
  29. typedef unsigned char UCHAR;
  30.  
  31. struct    FIELD_RECORD                    /* This structure is filled in memory */
  32. {                                                /* with a fread.    do not change. */
  33.         char     name[11];                    /* name of field in asciz */
  34.         char     typ;                             /* type of field...char,numeric etc. */
  35.         char *field_data_address;         /* offset of field in record */
  36.         #if defined(__TINY__) || defined(__SMALL__) || defined (__MEDIUM__)
  37.         int space_holder;                    /* field_data_address must be 32 bits */
  38.         #endif
  39.         UCHAR    len;                             /* length of field */
  40.         UCHAR    dec;                             /* decimals in field */
  41.         UCHAR    reserved_bytes[14];        /* reserved by dbase */
  42. };
  43.  
  44. struct    DBF
  45. {
  46.         char filename[MAXPATH];                    /* dos filename */
  47.         FILE *file_ptr;                        /* c file pointer */
  48.         unsigned long int current_record;/* current record in memory */
  49.         enum                                         /* status of file */
  50.         {
  51.             not_open=0,
  52.             not_updated,
  53.             updated
  54.         } status;
  55.         UCHAR    num_fields;                         /* number of fields */
  56.  
  57.         /* the following 7 variables are filled with a fread, do not change order or size */
  58.         UCHAR    dbf_version;                    /* version character */
  59.         UCHAR    update_yr;                        /* date of last update - year    (-1900) */
  60.         UCHAR    update_mo;                        /* date of last update - month */
  61.         UCHAR    update_day;                         /* date of last update - day    */
  62.         unsigned long int records;            /* number of records in dbf */
  63.         unsigned int    header_length;        /* length of header structure */
  64.         unsigned int    record_length;        /* length of a record */
  65.         /*                                                             */
  66.         struct FIELD_RECORD *fields_ptr;    /* pointer to field array */
  67.         char *record_ptr;                         /* pointer to current record struct */
  68. };
  69.  
  70. int d_addrec(struct DBF *d);
  71. int d_blank(struct DBF *d);
  72. int d_close(struct DBF *d);
  73. int d_cpystr(struct DBF *s,struct DBF *d);
  74. char d_getfld(struct DBF *d,int f,char *buff);
  75. int d_getrec(struct DBF *d,unsigned long int r);
  76. int d_open(struct DBF *d);
  77. int d_putfld(struct DBF *d,int f,char *buff);
  78. int d_putrec(struct DBF *d,unsigned long int r);
  79.  
  80.